import { Animation, Label, _decorator } from "cc";
import { InjectableComponent } from "../../inject";
const { ccclass, property } = _decorator;

@ccclass('TipsComp')
export default class TipsComp extends InjectableComponent {
    @property(Label)
    private lab_content: Label | null = null;

    @property(Animation)
    private animation: Animation | null = null;

    onLoad() {
        super.onLoad();

        if (this.animation)
            this.animation.on(Animation.EventType.FINISHED, this.onFinished, this);
    }

    private onFinished() {
        this.node.destroy();
    }

    public toast(msg: string) {
        this.lab_content!.string = msg;
    }
}